package com.jz.netthings.bloodsources.service.impl;

import com.jz.netthings.application.bodyCheck.bean.MyPage;
import com.jz.netthings.bloodsources.bean.XyNoPulping;
import com.jz.netthings.bloodsources.bean.XyRemind;
import com.jz.netthings.bloodsources.mapper.XyLinkMapper;
import com.jz.netthings.bloodsources.mapper.XyNoPulpingMapper;
import com.jz.netthings.bloodsources.service.XyNoPulpingService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jz.netthings.exception.AdscmSystemException;
import com.jz.netthings.security.utils.Token;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 未献浆记录表 服务实现类
 * </p>
 *
 * @author 张凡
 * @since 2019-08-13
 */
@Service
public class XyNoPulpingServiceImpl extends ServiceImpl<XyNoPulpingMapper, XyNoPulping> implements XyNoPulpingService {
    @Autowired
    private XyNoPulpingMapper xyNoPulpingMapper;
    @Override
    public Boolean insertXyNoPulpingInfo(List<XyNoPulping> xyNoPulpingList, Token token) throws AdscmSystemException {
        boolean b = super.insertBatch(xyNoPulpingList);
        return b;
    }

    @Override
    public Boolean updateByProviderId(XyNoPulping xyNoPulping) throws AdscmSystemException {

//        xyNoPulpingMapper.updateForSet()

        return xyNoPulpingMapper.updateByProviderId(xyNoPulping);
    }

    @Override
    public Boolean updateByNoPulpingInfo(XyNoPulping xyNoPulping) throws AdscmSystemException {
        Boolean b = false;
        b = super.updateById(xyNoPulping);
        return b;
    }

    @Override
    public List<XyNoPulping> queryXyNoPulpingByProviderId(Integer providerId,Integer isAgingPulping) throws AdscmSystemException {
        return xyNoPulpingMapper.queryXyNoPulpingByProviderId(providerId,isAgingPulping);
    }

    @Override
    public MyPage<XyNoPulping> queryByCondition(Integer nurseId, String nurseName, String nurseDeptId, String providerName, String createTimeLess, String createTimeGreater, String currentPage, String pageSize) throws AdscmSystemException {
        //进行分页数据判定
        MyPage<XyNoPulping> myPage=new MyPage<XyNoPulping>();
        myPage.setCurrentPageIndex(Integer.parseInt(currentPage));
        myPage.setPageSize(Integer.parseInt(pageSize));
        //对当前页参数currentPage 进行重新定义，为节省JVM资源开销，直接将计算后的开始页赋值给参数变量currentPage = beginIndex
        currentPage = myPage.getBeginIndex()+"";
        Integer count = xyNoPulpingMapper.queryByCount(nurseId,nurseName,nurseDeptId,providerName,createTimeLess,createTimeGreater);
        List<XyNoPulping> list  = xyNoPulpingMapper.queryByCondition(nurseId,nurseName,nurseDeptId,providerName,createTimeLess,createTimeGreater,Integer.parseInt(currentPage),Integer.parseInt(pageSize));
        //获取相关数据
        myPage.setItems(list);
        myPage.setTotal(count);
        return myPage;
    }

    @Override
    public Boolean updateXyNoPulpingInfo(XyNoPulping xyNoPulping) throws AdscmSystemException {
        return null;
    }
}
